/*
 * @Description:
 * @Author: gaoyunpeng
 * @Date: 2022-01-18 21:45:14
 * @LastEditors: gaoyunpeng
 */
const px2rem = require('postcss-px2rem');
const path = require('path');
function resolve(dir) {
  return path.join(__dirname, dir);
}
// 配置基本大小
const postcss = px2rem({
  // 基准大小 需要和 rem.js 中相同
  remUnit: 16
});
module.exports = {
  chainWebpack(config) {
    // set svg-sprite-loader
    config.module
      .rule('svg')
      .exclude.add(resolve('src/icons'))
      .end();
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('src/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
      .end();
  },
  css: {
    loaderOptions: {
      postcss: {
        plugins: [postcss]
      }
    }
  }
};
